@extends('layouts.console_header')

@section('title', '用户对账单')

@section('resources')
    @parent
    <style>
        nav{height: 50px;line-height: 50px;}
        nav a,nav span{margin-left: 20px;}
        nav input{margin-left: 20px;height: 28px;border: 1px solid #000;margin-top: 10px;}
    </style>
@endsection

@section('content')
<!--  html内容  -->
<section class="user_list">
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
		<p class="fz_14 account_title fl" style="border: none;">
		    <span style="color: #7f7f7f;"><a href="/console/index">首页</a>>财务中心></span>
		    <span class="co_violet">用户对账单</span>
		</p>
		<a href="#" onclick="export_data()"><p class="fr tc back_btn">导出</p></a>
	</div>
	<nav>
        <a class="fl" href="/console/finance/user/statement?cityid={{$cityid}}&type=today">今日</a>
        <a class="fl" href="/console/finance/user/statement?cityid={{$cityid}}&type=yesterday">昨日</a>
        <a class="fl" href="/console/finance/user/statement?cityid={{$cityid}}&type=week">本周</a>
        <a class="fl" href="/console/finance/user/statement?cityid={{$cityid}}&type=thismonth">本月</a>
        <a class="fl" href="/console/finance/user/statement?cityid={{$cityid}}&type=lastmonth">上月</a>
        <a class="fl" href="/console/finance/user/statement?cityid={{$cityid}}&type=all">全部</a>
        <span class="fl">时段选择</span>
        <input class="fl" type="date" name="starttime" value="{{date('Y-m-d', strtotime($starttime))}}" onchange="select_date()">
        <span class="fl">至</span>
        <input class="fl" type="date" name="lasttime" value="{{date('Y-m-d', strtotime($lasttime))}}" onchange="select_date()">
    </nav>
	<table class="finance_top_list">
		<tr>
			<th>充值笔数</th>
			<th>消费笔数</th>
			<th>充值金额(元)</th>
			<th>实付金额</th>
			<th>充值等待到账</th>
			<th>前系统打赏(元)</th>
			<th>可用余额</th>
		</tr>
		<tr>
			<td>{{$rechargenum}}</td>
			<td>{{$ordernum}}</td>
			<td>{{$rechargemoney}}</td>
			<td>{{$ordermoney}}</td>
			<td>{{$doublemoney}}</td>
			<td>8.265</td>
			<td>{{$balance}}</td>
		</tr>
	</table>
	<table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>序号</th>
                <th>用户昵称</th>
                <th>用户账号</th>
                <th>充值金额(元)</th>
                <th>已到账金额</th>
                <th>待到账金额</th>
                <th>实付金额</th>
                <th>可用余额</th>
                <th>操作</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>序号</th>
                <th>用户昵称</th>
                <th>用户账号</th>
                <th>充值金额(元)</th>
                <th>已到账金额</th>
                <th>待到账金额</th>
                <th>实付金额</th>
                <th>可用余额</th>
                <th>操作</th>
            </tr>
        </tfoot>
        <tbody>
        @foreach($data as $list)
            <tr>
                <td>{{$list['userid']}}</td>
                <td>{{$list['nickname']}}</td>
                <td>{{$list['mobile']}}</td>
            @if($list['rechargemoney'] != '')
                <td>{{$list['rechargemoney']}}</td>
            @else
                <td>--</td>
            @endif
            @if($list['isdouble'] != '')
                <td>{{$list['isdouble']}}</td>
            @else
                <td>--</td>
            @endif
            @if($list['notdouble'] != '')
                <td>{{$list['notdouble']}}</td>
            @else
                <td>--</td>
            @endif
            @if($list['actualamount'] != '')
                <td>{{$list['actualamount']}}</td>
            @else
                <td>--</td>
            @endif
            @if(($list['balance'] == 0)||($list['balance'] == ''))
                <td>--</td>
            @else
                <td>{{$list['balance']}}</td>
            @endif
                <td>
                    <a class="revise co_violet" href="/console/finance/recharge/get?cityid={{$cityid}}&userid={{$list['userid']}}">充值明细</a>
                    <a class="forbidden co_violet" href="/console/finance/consume/get?cityid={{$cityid}}&userid={{$list['userid']}}">消费明细</a>
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
        var cityid='{{$cityid}}';
        var str = window.location.href;
        if(str.indexOf("today") > 0){
            $("nav a").eq(0).css({"color": "#9955c6"});
        }else if(str.indexOf("yesterday") > 0){
            $("nav a").eq(1).css({"color": "#9955c6"});
        }else if(str.indexOf("week") > 0){
            $("nav a").eq(2).css({"color": "#9955c6"});
        }else if(str.indexOf("thismonth") > 0){
            $("nav a").eq(3).css({"color": "#9955c6"});
        }else if(str.indexOf("lastmonth") > 0){
            $("nav a").eq(4).css({"color": "#9955c6"});
        }else if(str.indexOf("all") > 0){
            $("nav a").eq(5).css({"color": "#9955c6"});
        }
        function select_date() {
            var startTime = $("input[name='starttime']").val();
            var lastTime = $("input[name='lasttime']").val();
            if(!startTime || !lastTime) {
                alert('请选择开始时间和结束时间'); return;
            }
            window.location.href="/console/finance/user/statement?cityid=" + cityid+"&starttime="+startTime+"&lasttime="+lastTime;
        }
        function export_data() {
            var startTime = $("input[name='starttime']").val();
            var lastTime = $("input[name='lasttime']").val();
            if(!startTime || !lastTime) {
                alert('请选择开始时间和结束时间'); return;
            }
            window.open("/console/finance/user/statement/export?cityid="+cityid+"&starttime="+startTime+"&lasttime="+lastTime, '_blank');
        }
    </script>
@endsection